<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Log/classes/PhpFox_ComponentPageSessions.class.php, $Author:  $ */



/** Component for browsing page sessions
 * 
 * @version $Id: PhpFox_ComponentPageSessions.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 * @package module.log
 *   
 */
class PhpFox_Mod_Log_ComponentPageSessions extends BaseComponent
{
    /** Processing method
     */
    
    function process()
    {

        $oReq = &App::getRequest();
        /* @var $oReq Request */

        $sUser = $oReq->get('user', null);
        
        switch($oReq->getAction())
        {
            case 'log_set_user':
                $oUrl = &App::getUrl();
                $oUrl->setParam('user', $sUser);
                $oUrl->clearParams('page');
                App::forward($oUrl->getUrl());
                break;
        }
        
        $oPage = $this->_oModule->getItem('Page');
        $sOrder = 'ID desc';
        $aCond = $sUser ? array('user'=>' = "'.$sUser.'"') : array();
        
        $iPageSize = $sUser ? 10000 : App::getParam('admin.pagesize');
        $iPage = $oReq->getInt('page', 1);
        list($aItems, $iCnt) = $oPage->getList($aCond, $iPage, $iPageSize, $sOrder);
        $oPager = App::newObject('Pager', $iCnt, $iPage, $iPageSize);
        
        $oTpl = &$this->_oModule->getTemplate();
        $oTpl->assign(array(
            'aItems'    => $aItems,
            'aPaging'   => $oPager->getInfo(App::getUrl()),
            'sUser'     => $sUser,
        ));
        $srcHtml = $oTpl->fetch('PageSessions.html');
        return $srcHtml;
    }
}
?>